﻿using Panuon.UI.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using WaveringLand_Launcher.Helper;
using WaveringLand_Launcher.Model;

namespace WaveringLand_Launcher.ViewModel.Component
{
    [PropertyChanged.AddINotifyPropertyChangedInterface]
    public class ResFileViewModel
    {
        public string Path =>WllFile.Path;
        public string Url => WllFile.Url;   
        public string MD5 => WllFile.MD5;
        public string Category => WllFile.Category;

        public WllFile WllFile { get; set; }

        public bool NeedUpdate { get; set; } = false;
        public bool IsDownloading { get; set; } = false;
        public int DownloadProgress { get; set; } = 0;

        public ICommand DownloadResCommand { get; set; }

        public ResFileViewModel()
        {
            DownloadResCommand = new RelayCommand(DownloadRes);
        }

        void DownloadRes(object sender)
        {
            WlTaskHelper.CreateDownloadTask(this, ()=> { App.Current.Dispatcher.Invoke(()=> {
                GameResourcesViewModel.Instance.GetLatestBtnClickCommand.Execute(this);
            }); });
        }

    }
}
